QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    hello.cuh \
    mainwindow.h

FORMS += \
    mainwindow.ui

# Default rules for deployment.
target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

###########################CUDA CONFIG####################################
LIBS += -L'/usr/local/cuda-12.6/targets/aarch64-linux/lib' -lcudart
INCLUDEPATH += '/usr/local/cuda-12.6/targets/aarch64-linux/include'
DEPENDPATH += '/usr/local/cuda-12.6/targets/aarch64-linux/lib'

CUDA_DIR="/usr/local/cuda-12.6"
CUDA_SDK="/usr/local/cuda-12.6"
QMAKE_LIBDIR += $$CUDA_DIR/targets/aarch64-linux/lib

NVCCFLAGS = --use_fast_math
CUDA_INC = $$join("/usr/local/cuda-12/targets/aarch64-linux/include",'" -I"','-I"','"')

# MSVCRT link option (static or dynamic, it must be the same with your Qt SDK link option)
CUDA_OBJECTS_DIR = ./

CUDA_SOURCES+=./hello.cu

CONFIG(debug, debug|release) {
    # Debug mode
    cuda_d.input = CUDA_SOURCES
    cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}algorithm.o
    cuda_d.commands = $$CUDA_DIR/bin/nvcc --device-debug --debug -gencode arch=compute_52,code=sm_52 -ccbin $$QMAKE_CXX \
                           -c ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
    cuda_d.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
# Release mode
    cuda.input = CUDA_SOURCES
    cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}algorithm.o
    cuda.commands = $$CUDA_DIR/bin/nvcc --cudart=static -ccbin $$QMAKE_CXX -gencode arch=compute_52,code=sm_52 -gencode arch=compute_52,code=compute_52 \
                        -c ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
    cuda.dependency_type = TYPE_C
    QMAKE_EXTRA_COMPILERS += cuda
}

